package com.practice.communication.aio;

import java.util.concurrent.atomic.AtomicInteger;

public class Server {
	
	private static int SERVER_DEFAULT_PORT = 8080;
	
	private static ServerAsyncHandler serverHandler;
	
	public static AtomicInteger clientCount = new AtomicInteger(0);
	
	public static void start() {
		start(SERVER_DEFAULT_PORT);
	};
	
	public synchronized static void start(int port) {
		if (serverHandler != null) return;
		
		serverHandler = new ServerAsyncHandler(port);
		new Thread(serverHandler, "Server").start();
	}
	
	public static void main(String[] args) {
		Server.start();
	}

}
